package cz.schovjan.proj.controllers;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import cz.schovjan.proj.util.StringUtil;

/**
 * Kontroler pro chybu.
 * @author schovjan
 *
 */
@Controller
public class ErrorController {
	
	/** stranka s chybou */
	private static final String ERROR = "error";
	
	
	/////////////////
	//OBSLUZNE FUKNCE ------------------------------------------------------------
	/////////////////
	
	
	/**
	 * Zobrazeni stranky s chybou.
	 * @param model
	 * @param message
	 * @return
	 */
	@RequestMapping(value="/error/{message}")
	public String error(ModelMap model, @PathVariable("message") String message) {
		model.addAttribute("message", StringUtil.fromSecretString(message));
		
		return ERROR;
	}
	
}
